import Data.List
import Names

sortedNames = buildNames [1..] (sort names)

buildNames :: [Int] -> [String] -> [(Int,String,Int)]
buildNames _ [] = []
buildNames (n:ns) (name:names) = (n,name,abValue name * n) : buildNames ns names

abValue [] = 0
abValue (x:xs) = abValue' x + abValue xs

main = sum (map (\(x,y,val) -> val) sortedNames)

abValue' 'A' = 1
abValue' 'B' = 2
abValue' 'C' = 3
abValue' 'D' = 4
abValue' 'E' = 5
abValue' 'F' = 6
abValue' 'G' = 7
abValue' 'H' = 8
abValue' 'I' = 9
abValue' 'J' = 10
abValue' 'K' = 11
abValue' 'L' = 12
abValue' 'M' = 13
abValue' 'N' = 14
abValue' 'O' = 15
abValue' 'P' = 16
abValue' 'Q' = 17
abValue' 'R' = 18
abValue' 'S' = 19
abValue' 'T' = 20
abValue' 'U' = 21
abValue' 'V' = 22
abValue' 'W' = 23
abValue' 'X' = 24
abValue' 'Y' = 25
abValue' 'Z' = 26


